<template>
  <!-- 出勤天数 -->
  <div class="app-container">
    <el-form :inline="true" :model="Search" size="mini" class="demo-form-inline">
      <el-form-item label="输送机构: " prop="Search">
        <el-input v-model="Search.Conveyingmechanism" placeholder="输送机构" />
      </el-form-item>


      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="getDataList">查询</el-button>
        <el-button type="success" icon="el-icon-circle-plus-outline" size="mini" @click="add">新增</el-button>
      </el-form-item>
    </el-form>

    <div style="width: 100%;">
      <el-table style="width: 100%;" :data="datalist" size="mini" border @sort-change="sortChange">
        <el-table-column align="center" label="登记表编号" width="110px" fixed>
          <template slot-scope="scope">
            {{ scope.row.TemporaryCostRecordNo }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="输送类别">
          <template slot-scope="scope">
            {{ scope.row.DeliverType==1?'学校':'企业' }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="输送机构" width="150px">
          <template slot-scope="scope">
            {{ scope.row.Conveyingmechanism }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="输送期限开始" width="150px">
          <template slot-scope="scope">
            {{ scope.row.StratConveyorDate }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="输送期限结束" width="150px">
          <template slot-scope="scope">
            {{ scope.row.EndConveyorDate }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="输送月数">
          <template slot-scope="scope">
            <span v-if="scope.row.Months===1">未满一个月</span>
            <span v-if="scope.row.Months===2">小于两个月</span>
            <span v-if="scope.row.Months===3">大于等于两个月</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="岗位">
          <template slot-scope="scope">
            {{ scope.row.Post }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="管理费计算方式" width="110px">
          <template slot-scope="scope">
            <span v-if="scope.row.TemporaryCostType===1">按月计算</span>
            <span v-if="scope.row.TemporaryCostType===3">按小时计算</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="计算方式" width="110px">
          <template slot-scope="scope" v-if="scope.row.TemporaryCostType == 3">
            <span v-if="scope.row.CalculationMethod===1">借调单位(无管理费)</span>
            <span v-if="scope.row.CalculationMethod===2">借调单位(有管理费)</span>
            <span v-if="scope.row.CalculationMethod===3">新宝(有管理费)</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="驻场人员费用">
          <template slot-scope="scope">
            {{ scope.row.ResidentPersonnelCost }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="驻厂人员人数">
          <template slot-scope="scope">
            {{ scope.row.ResidentPersonnelNum }}
          </template>
        </el-table-column>

        <el-table-column align="center" label="预计报道人数">
          <template slot-scope="scope">
            {{ scope.row.ReportNum }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="联系人">
          <template slot-scope="scope">
            {{ scope.row.Contacts }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="联系方式" width="100px">
          <template slot-scope="scope">
            {{ scope.row.Tell }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="工资单价">
          <template slot-scope="scope">
            {{ scope.row.WageAmount }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="管理费出勤天数">
          <template slot-scope="scope">
            {{ scope.row.TemporaryCostDay }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="车费出勤天数">
          <template slot-scope="scope">
            {{ scope.row.TemporaryCostCarDay }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="管理费金额">
          <template slot-scope="scope" v-if="scope.row.CalculationMethod ==2 ||scope.row.CalculationMethod==3 ||scope.row.TemporaryCostType==1">
            {{ scope.row.TemporaryCost }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="车费金额">
          <template slot-scope="scope">
            {{ scope.row.CarCost }}
          </template>
        </el-table-column>

        <el-table-column align="center" label="批次">
          <template slot-scope="scope">
            {{ scope.row.Batch }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="操作" width="150px" fixed="right">
          <template slot-scope="scope">
            <el-button type="primary" icon="el-icon-edit" circle size="small" @click="edit(scope)"></el-button>
            <el-button type="danger" icon="el-icon-delete" circle size="small" @click="delData(scope)"></el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>

  <div id="son" style="float: right;">
    <el-pagination background layout="sizes, prev, pager, next,total" :page-size="Search.pageSize" :total="Search.total"
      @current-change="pageChange" />
  </div>

  </div>






</template>

<script>
  import path from 'path'
  import {
    deepClone
  } from '@/utils'
  import {
    getDataList,deleteCostRecord,deleteDetail
  } from '@/api/school'

  export default {

    data() {
      return {
        datalist: [],
        Search: { // 查询条件
          total: 0, // 总记录数
          pageSize: 10, // 一页显示的记录数
          page: 1, // /当前页码
          RNO: '006', // 表编号  根据Controller中对应的表编号
          jsWhere: '' // 自定义条件
        }
      }
    },
    computed: {

    },
    created() {
      this.getDataList()
    },
    methods: {
      pageChange(page) { // 翻页
        this.Search.page = page
        this.getDataList()
      },
      async getDataList() { // 获取列表数据，通用
        this.Search.DeliverType = 2
        const res = await getDataList({
          data: JSON.stringify(this.Search)
        })
        this.datalist = res.data.Table //将data 中的数据放到queueList中
        this.Search.total = res.data.Table1[0].RecordCount

      },
      add(){
        this.$router.push({
          path: '/TemporaryLaborCostsE'
        })
      },
      async edit(scope) {
        this.$router.push({
          path: '/TemporaryLaborCostsE',
          query: {
            JumpID: scope.row.TemporaryCostRecordNo
          }
        })
      },
	  delData({
	    $index,
	    row
	  }) {
	    if (row.TemporaryCostRecordNo != undefined) {
	      this.$confirm('确定删除 ' + row.TemporaryCostRecordNo + ' 的数据吗?', {
	        confirmButtonText: '确认',
	        cancelButtonText: '取消',
	        type: 'warning'
	      }).then(async () => {
	        await deleteCostRecord({
	          ID: JSON.stringify(row.TemporaryCostRecordNo)
	        })
	        this.datalist.splice($index, 1)
          await deleteDetail({
            billID: row.TemporaryCostRecordNo,
            dataBase: "TLC_FactoryStaff",
            name: "TemporaryCostRecordNo"
          })
	      })

	    } else {
	      this.datalist.splice($index, 1);
	    }
	  }
    }
  }
</script>

<style>
</style>
